package org.brain.bean;

import org.brain.dbo.DBOperate;
import org.brain.pojos.*;
import org.brain.tool.ToolBean;

import java.util.List;
import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;

@ManagedBean(name="showDateBean")
@SessionScoped

public class ShowDateBean {
	
	List<Document> docList = new ArrayList<Document>();//docuemnt List
	String id; //docuemnt id
	String idReserve; //
	int row = 0;
	
	/*
	 * get id from URI
	 * */
	
	public ShowDateBean() {
		// TODO Auto-generated constructor stub
		
		
	}
	/*
	 * init document list from database
	 * 
	 * */
	
	public void initList()
	{
		id = ToolBean.getRequestParameter("id"); 
		//当点击导航按钮时，会发送一个请求。默认是不带id参数的。这个我们为它，记录一个参数 
		if(id!=null)
			idReserve = id;
		else
			id = idReserve;
		docList.clear();
		docList = DBOperate.search("Document where nodeid="+id);
		row=docList.size();
		System.out.println("documentid "+id);
		
	}
	
	public List<Document> getDocList() {
		
		return docList;
	}
	public void setDocList(List<Document> docList) {
		this.docList = docList;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}

	public int getRow() {
		initList();
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}
	
	

}
